package question18;

import java.util.Scanner;

public class LoginDemo {
    public static void main(String[] args) {
        User user = new User("admin", "admin");
        login(user);
    }
    public static void login(User user){
        Scanner sc=new Scanner(System.in);
        System.out.println("输入用户名");
       String usename=sc.nextLine();
       if (!usename.equals(user.getName())){
           throw new LoginException("用户名错误");
       }else{
       System.out.println("输入密码");
       String password=sc.nextLine();
       if (!password.equals(user.getPassword())){
           throw new LoginException("密码错误");
       }else System.out.println("欢迎登录");
       }
    }
}
